p_height=9;
p_width=7;

output_name="/Volumes/Data/gSVN/ethernet-switch/paper/figures/900_300.eps"

#quartz();
postscript(output_name, height=p_height, width=p_width, horizontal=FALSE, onefile=TRUE);

#The four numbers in the call to par are the number of lines of text reserved on the bottom, left, top and right, respectively, ps: text size, mpg: margin size for title, axis label and axis
saved_par=par(mar=c(2.5,2.5,0,2)+0.1, ps=10, mgp=c(1.2,0.5,0), mfrow=c(6,1));

#3COM real
#parameters to change
my_dir="/Volumes/Data/gSVN/ethernet-switch/paper/plots/900_300_two_flows_group/3COM_real/";
x_max=1400;
x_min=-20;
y_min=-5;
y_max=190;
x_label=expression(paste("Arrival Time(", mu, "s)    (a1)", sep=""));

flow1_time_filename=paste(my_dir, "900_300_flow1_time.txt", sep="");
flow1_delay_filename=paste(my_dir, "900_300_flow1_delay.txt", sep="");
flow2_time_filename=paste(my_dir, "900_300_flow2_time.txt", sep="");
flow2_delay_filename=paste(my_dir, "900_300_flow2_delay.txt", sep="");

flow1_time=scan(file=flow1_time_filename);
flow1_delay=scan(file=flow1_delay_filename);
flow2_time=scan(file=flow2_time_filename);
flow2_delay=scan(file=flow2_delay_filename);

plot(flow1_time, flow1_delay, col='black', type='p', xlab=NA, ylab=NA,ylim=c(y_min,y_max), xlim=c(x_min, x_max), xaxs='i', yaxs='i');

points(flow2_time, flow2_delay, col='red', pch=19, type='p');

title(main=NA, ylab=expression(paste("Delay(", mu, "s)/Loss", sep="")), xlab=x_label);

legend('topleft', legend=c('900 Mb/s Flow', '300 Mb/s Flow'), col=c('black', 'red'), pch=21:19, bty='n');

#3COM queue
#parameters to change
my_dir="/Volumes/Data/gSVN/ethernet-switch/paper/plots/900_300_two_flows_group/3COM_queue/";
x_max=1400;
x_min=-20;
y_min=-5;
y_max=190;
x_label=expression(paste("Arrival Time(", mu, "s)    (a2)", sep=""));

flow1_time_filename=paste(my_dir, "900_300_flow1_time.txt", sep="");
flow1_delay_filename=paste(my_dir, "900_300_flow1_delay.txt", sep="");
flow2_time_filename=paste(my_dir, "900_300_flow2_time.txt", sep="");
flow2_delay_filename=paste(my_dir, "900_300_flow2_delay.txt", sep="");

flow1_time=scan(file=flow1_time_filename);
flow1_delay=scan(file=flow1_delay_filename);
flow2_time=scan(file=flow2_time_filename);
flow2_delay=scan(file=flow2_delay_filename);

plot(flow1_time, flow1_delay, col='black', type='p', xlab=NA, ylab=NA,ylim=c(y_min,y_max), xlim=c(x_min, x_max), xaxs='i', yaxs='i');

points(flow2_time, flow2_delay, col='red', pch=19, type='p');

title(main=NA, ylab=expression(paste("Delay(", mu, "s)/Loss", sep="")), xlab=x_label);

legend('topleft', legend=c('900 Mb/s Flow', '300 Mb/s Flow'), col=c('black', 'red'), pch=21:19, bty='n');

#3COM simplified
#parameters to change
my_dir="/Volumes/Data/gSVN/ethernet-switch/paper/plots/900_300_two_flows_group/3COM_simplified_queue/";
x_max=1400;
x_min=-20;
y_min=-5;
y_max=190;
x_label=expression(paste("Arrival Time(", mu, "s)    (a3)", sep=""));

flow1_time_filename=paste(my_dir, "900_300_flow1_time.txt", sep="");
flow1_delay_filename=paste(my_dir, "900_300_flow1_delay.txt", sep="");
flow2_time_filename=paste(my_dir, "900_300_flow2_time.txt", sep="");
flow2_delay_filename=paste(my_dir, "900_300_flow2_delay.txt", sep="");

flow1_time=scan(file=flow1_time_filename);
flow1_delay=scan(file=flow1_delay_filename);
flow2_time=scan(file=flow2_time_filename);
flow2_delay=scan(file=flow2_delay_filename);

plot(flow1_time, flow1_delay, col='black', type='p', xlab=NA, ylab=NA,ylim=c(y_min,y_max), xlim=c(x_min, x_max), xaxs='i', yaxs='i');

points(flow2_time, flow2_delay, col='red', pch=19, type='p');

title(main=NA, ylab=expression(paste("Delay(", mu, "s)/Loss", sep="")), xlab=x_label);

legend('topleft', legend=c('900 Mb/s Flow', '300 Mb/s Flow'), col=c('black', 'red'), pch=21:19, bty='n');

#NG real
#parameters to change
my_dir="/Volumes/Data/gSVN/ethernet-switch/paper/plots/900_300_two_flows_group/NG_real/";
x_max=2500;
x_min=-20;
y_min=-5;
y_max=300;
x_label=expression(paste("Arrival Time(", mu, "s)    (b1)", sep=""));

flow1_time_filename=paste(my_dir, "900_300_flow1_time.txt", sep="");
flow1_delay_filename=paste(my_dir, "900_300_flow1_delay.txt", sep="");
flow2_time_filename=paste(my_dir, "900_300_flow2_time.txt", sep="");
flow2_delay_filename=paste(my_dir, "900_300_flow2_delay.txt", sep="");

flow1_time=scan(file=flow1_time_filename);
flow1_delay=scan(file=flow1_delay_filename);
flow2_time=scan(file=flow2_time_filename);
flow2_delay=scan(file=flow2_delay_filename);

plot(flow1_time, flow1_delay, col='black', type='p', xlab=NA, ylab=NA,ylim=c(y_min,y_max), xlim=c(x_min, x_max), xaxs='i', yaxs='i');

points(flow2_time, flow2_delay, col='red', pch=19, type='p');

title(main=NA, ylab=expression(paste("Delay(", mu, "s)/Loss", sep="")), xlab=x_label);

legend('topleft', legend=c('900 Mb/s Flow', '300 Mb/s Flow'), col=c('black', 'red'), pch=21:19, bty='n');

#NG queue
#parameters to change
my_dir="/Volumes/Data/gSVN/ethernet-switch/paper/plots/900_300_two_flows_group/NG_queue/";
x_max=2500;
x_min=-20;
y_min=-5;
y_max=300;
x_label=expression(paste("Arrival Time(", mu, "s)    (b2)", sep=""));

flow1_time_filename=paste(my_dir, "900_300_flow1_time.txt", sep="");
flow1_delay_filename=paste(my_dir, "900_300_flow1_delay.txt", sep="");
flow2_time_filename=paste(my_dir, "900_300_flow2_time.txt", sep="");
flow2_delay_filename=paste(my_dir, "900_300_flow2_delay.txt", sep="");

flow1_time=scan(file=flow1_time_filename);
flow1_delay=scan(file=flow1_delay_filename);
flow2_time=scan(file=flow2_time_filename);
flow2_delay=scan(file=flow2_delay_filename);

plot(flow1_time, flow1_delay, col='black', type='p', xlab=NA, ylab=NA,ylim=c(y_min,y_max), xlim=c(x_min, x_max), xaxs='i', yaxs='i');

points(flow2_time, flow2_delay, col='red', pch=19, type='p');

title(main=NA, ylab=expression(paste("Delay(", mu, "s)/Loss", sep="")), xlab=x_label);

legend('topleft', legend=c('900 Mb/s Flow', '300 Mb/s Flow'), col=c('black', 'red'), pch=21:19, bty='n');

#NG analytical
#parameters to change
my_dir="/Volumes/Data/gSVN/ethernet-switch/paper/plots/900_300_two_flows_group/NG_analytical/";
x_max=2500;
x_min=-20;
y_min=-5;
y_max=300;
x_label=expression(paste("Arrival Time(", mu, "s)    (b3)", sep=""));

flow1_time_filename=paste(my_dir, "900_300_flow1_time.txt", sep="");
flow1_delay_filename=paste(my_dir, "900_300_flow1_delay.txt", sep="");
flow2_time_filename=paste(my_dir, "900_300_flow2_time.txt", sep="");
flow2_delay_filename=paste(my_dir, "900_300_flow2_delay.txt", sep="");

flow1_time=scan(file=flow1_time_filename);
flow1_delay=scan(file=flow1_delay_filename);
flow2_time=scan(file=flow2_time_filename);
flow2_delay=scan(file=flow2_delay_filename);

plot(flow1_time, flow1_delay, col='black', type='p', xlab=NA, ylab=NA,ylim=c(y_min,y_max), xlim=c(x_min, x_max), xaxs='i', yaxs='i');

points(flow2_time, flow2_delay, col='red', pch=19, type='p');

title(main=NA, ylab=expression(paste("Delay(", mu, "s)/Loss", sep="")), xlab=x_label);

legend('topleft', legend=c('900 Mb/s Flow', '300 Mb/s Flow'), col=c('black', 'red'), pch=21:19, bty='n');

# end
par(saved_par);
dev.off()